Skip to content

Conversation

@risukun
Copy link

@risukun risukun commented Nov 12, 2025

Add FullTextTable class attribute & FullTextIndexed property attribute for easy FTS indexing

Add simple attribute support for full text indexing of a subset of columns in table as well as support to change the default tokenizer behavior [for the table. Porting a change that I did in a copy of SQLite.cs for a UWP Japanese dictionary app ~9 years ago that I'm now trying to port to MAUI. Added a bunch of unit tests to cover the functionality and confirmed the existing tests are all passing on Win11.

Note that this PR does NOT port custom tokenizer support that I also had added in order to use a Japanese word breaker, but I can work around that with pre-breaking using a .NET Japanese language model library as long as I can at least use the "unicode61" tokenizer instead of the default "simple" one that clobbers most Unicode characters.

Example usage:

	**[FullTextTable]**
	public class Article
	{
		[PrimaryKey, AutoIncrement]
		public int Id { get; set; }

		**[FullTextIndexed]**
		public string Title { get; set; }

		**[FullTextIndexed]**
		public string Content { get; set; }
		public string Author { get; set; }
		public DateTime PublishDate { get; set; }
	}

	**[FullTextTable("JapaneseText_FT", "unicode61")]**
	public class JapaneseText
	{
		[PrimaryKey, AutoIncrement]
		public int Id { get; set; }

		**[FullTextIndexed]**
		public string Text { get; set; }

		public string Notes { get; set; }
	}
	
	var query = "SELECT * FROM Article WHERE Id IN (SELECT docid FROM Article_FT WHERE Article_FT MATCH 'programming')";
	var results = db.Query<Article>(query);

…e for easy FTS indexing

Add simple attribute support for full text indexing of a subset of columns in table as well as support to change the default tokenizer behavior [for the table. Porting a change that I did in a copy of SQLite.cs for a UWP Japanese dictionary app ~9 years ago that I'm now trying to port to MAUI.  Added a bunch of unit tests to cover the functionality and confirmed the existing tests are all passing on Win11.

Example usage:

		[FullTextTable]
		public class Article
		{
			[PrimaryKey, AutoIncrement]
			public int Id { get; set; }

			[FullTextIndexed]
			public string Title { get; set; }

			[FullTextIndexed]
			public string Content { get; set; }
			public string Author { get; set; }
			public DateTime PublishDate { get; set; }
		}

				[FullTextTable("JapaneseText_FT", "unicode61")]
		public class JapaneseText
		{
			[PrimaryKey, AutoIncrement]
			public int Id { get; set; }

			[FullTextIndexed]
			public string Text { get; set; }

			public string Notes { get; set; }
		}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant